/*
 * @lc app=leetcode.cn id=168 lang=cpp
 *
 * [168] Excel表列名称
 */

// @lc code=start
class Solution {
public:
    string convertToTitle(int n) {
        string ans;
        while(n)
        {
            char tmp = 'A';
            char remainder = n % 26;
            if(remainder == 0)
            {
                tmp = 'Z';
                remainder = 26;
            }
            else
            {
                tmp += remainder - 1;
            }
            ans = tmp + ans;
            n -= remainder;
            n /= 26;
        }
        return ans;
    }
};
// @lc code=end

